package se.lnu.axez.animation;

import se.lnu.axez.FloatTriple;
import se.lnu.axez.IControl;

public final class TranslateControlAnimation extends Animation<IControl> {
	private float xFrom;
	private float xTo;
	private float yFrom;
	private float yTo;
	private float zFrom;
	private float zTo;
	
	public TranslateControlAnimation() {
	}
	
	public TranslateControlAnimation(FloatTriple from, 
			float xTo, float yTo, float zTo) {
		this(from.x(), from.y(), from.z(), xTo, yTo, zTo);
	}

	public TranslateControlAnimation(
			float xFrom, float yFrom, float zFrom, 
			float xTo, float yTo, float zTo) {
		this.xFrom = xFrom;
		this.xTo = xTo;
		this.yFrom = yFrom;
		this.yTo = yTo;
		this.zFrom = zFrom;
		this.zTo = zTo;
	}

	public float getxFrom() {
		return this.xFrom;
	}

	public void setXFrom(float xFrom) {
		this.xFrom = xFrom;
	}

	public float getxTo() {
		return this.xTo;
	}

	public void setXTo(float xTo) {
		this.xTo = xTo;
	}

	public float getyFrom() {
		return this.yFrom;
	}

	public void setYFrom(float yFrom) {
		this.yFrom = yFrom;
	}

	public float getyTo() {
		return this.yTo;
	}

	public void setYTo(float yTo) {
		this.yTo = yTo;
	}

	public float getzFrom() {
		return this.zFrom;
	}

	public void setZFrom(float zFrom) {
		this.zFrom = zFrom;
	}

	public float getzTo() {
		return this.zTo;
	}

	public void setZTo(float zTo) {
		this.zTo = zTo;
	}

	@Override
	protected void applyTransformation(float interpolatedTime, IControl targetObject) {
		float x = this.xFrom + ((this.xTo - this.xFrom) * interpolatedTime);
		float y = this.yFrom + ((this.yTo - this.yFrom) * interpolatedTime);
        float z = this.zFrom + ((this.zTo - this.zFrom) * interpolatedTime);
        targetObject.getTransformation().setTranslation(x, y, z);
	}
}
